﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cobit5.BIZ.Cobit
{
    public class TimeAlarmStatusInfo
    {
        #region Model
        private int currentStatus;
        /// <summary>
        /// Current Status
        /// </summary>
        public int CurrentStatus
        {
            get { return currentStatus; }
            //set { currentStatus = value; }
        }

        private int nextStatus;
        /// <summary>
        /// Next Status
        /// </summary>
        public int NextStatus
        {
            get { return nextStatus; }
            //set { nextStatus = value; }
        }

        private string submitName;
        /// <summary>
        /// The name of submit
        /// </summary>
        public string SubmitName
        {
            get { return submitName; }
            //set { submitName = value; }
        }
        #endregion Model

        /// <summary>
        /// Initialize, for internal use
        /// </summary>
        public TimeAlarmStatusInfo(int in_current, int in_next, string in_submit)
        {
            this.currentStatus = in_current;
            this.nextStatus = in_next;
            this.submitName = in_submit;
        }

        /// <summary>
        /// Get the next Status
        /// </summary>
        public static List<TimeAlarmStatusInfo> GetNextStatus(TimeAlarmStatus in_current)
        {
            return TimeAlarmStatusInfo.GetNextStatus((int)in_current);
        }
        /// <summary>
        /// Get the next Status
        /// </summary>
        public static List<TimeAlarmStatusInfo> GetNextStatus(int in_current)
        {
            List<TimeAlarmStatusInfo> returnTimeAlarms = new List<TimeAlarmStatusInfo>();

            if (in_current == 0)//Owner,Reviewer,Manager
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(0, 71, "建议新的时间");
                returnTimeAlarms.Add(new1);
            }
            else if (in_current == 11)//Owner
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(11, 12, "不再邮件提醒");
                TimeAlarmStatusInfo new3 = new TimeAlarmStatusInfo(11, 71, "建议新的时间");
                TimeAlarmStatusInfo new2 = new TimeAlarmStatusInfo(11, 81, "提交文件");
                returnTimeAlarms.Add(new1);
                returnTimeAlarms.Add(new2);
                returnTimeAlarms.Add(new3);
            }
            else if (in_current == 12)//Owner
            {
                TimeAlarmStatusInfo new2 = new TimeAlarmStatusInfo(12, 71, "建议新的时间");
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(12, 81, "提交文件");
                returnTimeAlarms.Add(new1);
                returnTimeAlarms.Add(new2);
            }
            else if (in_current == 21)//Owner
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(21, 22, "不再邮件提醒");
                TimeAlarmStatusInfo new3 = new TimeAlarmStatusInfo(21, 71, "建议新的时间");
                TimeAlarmStatusInfo new2 = new TimeAlarmStatusInfo(21, 81, "提交文件");
                returnTimeAlarms.Add(new1);
                returnTimeAlarms.Add(new2);
                returnTimeAlarms.Add(new3);
            }
            else if (in_current == 22)//Owner
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(22, 81, "提交文件");
                TimeAlarmStatusInfo new2 = new TimeAlarmStatusInfo(22, 71, "建议新的时间");
                returnTimeAlarms.Add(new1);
                returnTimeAlarms.Add(new2);
            }
            else if (in_current == 71)//Manager
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(71, 72, "提交新的时间");
                returnTimeAlarms.Add(new1);
            }
            else if (in_current == 81)//Reviewer
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(81, 82, "Review通过");
                TimeAlarmStatusInfo new2 = new TimeAlarmStatusInfo(81, 91, "Review不通过");
                returnTimeAlarms.Add(new1);
                returnTimeAlarms.Add(new2);
            }
            else if (in_current == 82)//Manager
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(82, 100, "审核通过");
                TimeAlarmStatusInfo new2 = new TimeAlarmStatusInfo(82, 92, "审核不通过");
                returnTimeAlarms.Add(new1);
                returnTimeAlarms.Add(new2);
            }
            else if (in_current == 91)//Owner
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(91, 81, "重新提交");
                returnTimeAlarms.Add(new1);
            }
            else if (in_current == 92)//Owner
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(92, 81, "重新提交");
                returnTimeAlarms.Add(new1);
            }
            else if (in_current == 100)//Owner,Reviewer
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(100, 101, "提交下一次执行时间");
                returnTimeAlarms.Add(new1);
            }
            else if (in_current == 101)//Manager
            {
                TimeAlarmStatusInfo new1 = new TimeAlarmStatusInfo(101, 102, "确定");
                TimeAlarmStatusInfo new2 = new TimeAlarmStatusInfo(101, 100, "建议修改时间");
            }

            return returnTimeAlarms;
        }

        /// <summary>
        /// Get the name of the status
        /// Parameters: 1.in_status: TimeAlarmStatus Enum
        /// Return:     1.name of the status
        /// </summary>
        public static string GetStatusName(TimeAlarmStatus in_status)
        {
            switch ((int)in_status)
            {
                case 0: return "尚未开始";

                case 11: return "开始执行";
                case 12: return "开始执行";

                case 21: return "时间截止";
                case 22: return "时间截止";

                case 71: return "建议新的时间";
                case 72: return "将按照新的时间执行";

                case 81: return "Owner提交待审批";
                case 82: return "Reviewer提交待入库";

                case 91: return "Owner提交被退回";
                case 92: return "Reviewer提交被退回";

                case 100: return "商定下个执行时间";
                case 101: return "重新商定执行时间";

                case 102: return "完整结束";

                default: return "状态出错";
            }

        }
    }
}
